/*
 * @lc app=leetcode.cn id=680 lang=typescript
 *
 * [680] 验证回文字符串 Ⅱ
 */

// @lc code=start
function validPalindrome(s: string): boolean {
    let i = 0;
    let j = s.length - 1;
    while (i <= j) {
        if (s[i] === s[j]) {
            i++;
            j--;
        } else {
            return (
                _validPalindrome(s.slice(i, j)) ||
                _validPalindrome(s.slice(i + 1, j + 1))
            );
        }
    }
    return true;
}
function _validPalindrome(s: string): boolean {
    let i = 0;
    let j = s.length - 1;
    while (i <= j) {
        if (s[i] === s[j]) {
            i++;
            j--;
        } else {
            return false;
        }
    }
    return true;
}
// @lc code=end
